package gamelog

import (
	"model"
	"time"
	"fmt"
)
type FarmPlantlog struct {
	Id uint  `gorm:"column:id"`
	AreaId uint `gorm:"column:areaId"`
	UserId uint `gorm:"column:userId"`
	ToUserId uint `gorm:"column:toUserId"`
	LType int8 `gorm:"column:lType"`
	LaunchTime time.Time `gorm:"column:launchTime"`
	LogMsg string `gorm:"column:logMsg"`
	GainNum int16 `gorm:"column:gainNum"`
}
type InteractLog struct {
	Id uint  `gorm:"column:id"`
	AreaId uint `gorm:"column:areaId"`
	UserId uint `gorm:"column:userId"`
	ToUserId uint `gorm:"column:toUserId"`
	WaterCount int8 `gorm:"column:waterCount"`
	IType int8 `gorm:"column:iType"`
	LogTime time.Time `gorm:"column:logTime"`
	Msg string `gorm:"column:msg"`
}
func AddPlantLog(f *FarmPlantlog) {
	var Db = model.DB("FarmPlantlog")
	defer Db.Close()
	var Layout = "20060102"
	d:=time.Now().Format(Layout)
	s:="plant_log_"+d
	if err:=Db.Table(s).Create(f).Error;err!=nil{
		fmt.Println(err)
	}
}
//获取今日给某好友浇水次数
func GetWaterNum(userId float64,toUserId float64)int8{
	var Db = model.DB("FarmPlantlog")
	defer Db.Close()
	var Layout = "20060102"
	d:=time.Now().Format(Layout)
	s:="plant_log_"+d
	where:=map[string]interface{}{"userId":userId,"toUserId":toUserId}
	var count int8 = 0
	Db.Table(s).Where(where).Count(&count)
	return count
}

